<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@page import="com.tueye.utils.TuEyeConstant"%>
 <%@page import="java.io.*"%>
<%@page import="com.tueye.entity.Topics"%>
<%@ include file="/common/include.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Topics topic = (Topics)request.getAttribute("topic");
String picturepath =  path + File.separator +topic.getTopic_type().getType_enlish_name()+ "/"+topic.getTopic_code()+File.separator;
  String pic_nameurl = topic.getTopic_type().getType_enlish_name()+ "/"+topic.getTopic_code()+File.separator;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<meta http-equiv="content-Type" content="text/html; charset=utf-8" />
		<title>注册页面</title>
		
		<meta name="robots" content="all" />
		<meta name="MSSmartTagsPreventParsing" content="true" />
		<meta http-equiv="imagetoolbar" content="false" />

	 
		<script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
		<script src="<%=path%>/script/grid/thickbox.js" type="text/javascript"></script>
		<script src="<%=path%>/script/tueyeutiljs.js" type="text/javascript"></script>
		<link rel="alternate stylesheet" type="text/css" href="<%=request.getContextPath() %>/themes/flexigrid/css/thickbox.css"  />
	</head>

	<body>
		<form method="post">
		<input name="id" id="id" type="hidden" value="${topic.id }" />
			<table>
				<tr>
					<td>
						<label for="projects">
							文章主题：
						</label>
						<input name="topic_title" id="topic_title" type="text" value="${topic.topic_title}" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							文章概述：
						</label>
						
						<textarea rows="5" cols="40" id="topic_overview" name="topic_overview">${topic.topic_overview}</textarea>
					</td>
				</tr>
				
				<tr>
					<td>
						<label for="projects">
							文章类型：
						</label>
					<select name="topic_type" id="topic_type">
	                     <c:forEach var="type" items="${types}">
	                          <option value="${type.id}" <c:if test="${type.type_name eq topic.topic_type.type_name }" > selected="selected" </c:if> >${type.type_name }</option>
	                     </c:forEach>
           			 </select>
					</td>
				</tr>
				
				<tr>
					<td>
						<label for="projects">
							关&nbsp;键&nbsp;字：
						</label>
						<input name="keywords" id="keywords" type="text" value="${topic.keywords}" size=24 />
						<img src="<%=path %>/themes/images/find3.gif" alt="查找" onclick="getKeyWord();"/>
						meta的keyword
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							文章作者：
						</label>
						<input name="topic_author" id="topic_author" type="text" value="${topic.topic_author}" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							文章转自：
						</label>
						<input name="topic_from" id="topic_from" type="text" value="${topic.topic_from}" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							文章SEO描述：
						</label>
						<input name="topic_description" id="topic_description" type="text" value="${topic.topic_description}" size=24 />
						meta中的description　
					</td>
				</tr>
				<!-- 图片列表 -->
				<tr>
					<td> 
						   <c:if test="${!empty topic.pictures }">
						   	 
									<h5 class="hfivepadding">查看图片:</h5>
										
         					 <c:forEach items="${topic.pictures }" var="picture">
         					 <p>
         					 <img src="<%=picturepath%>${picture.picture_url }" alt="${picture.picture_name }" onload="javascript:DrawImage(this,100,100)" />
         					 <img src="<%=path %>/themes/icons/delete.gif" onclick="deletePic('${picture.id }','<%=picturepath%>/${picture.picture_url }');"/>
         					 </p>
		                     </c:forEach>
         						 
							 
         					</c:if>
					</td>
				</tr>
				<tr>
					<td align="center">
						<input type="button" value="保存" onclick="savePageName()" />
						<input type="button" value="返回" onclick="javascript:history.back();" />
						&nbsp;&nbsp;
					</td>
				</tr>


			</table>
		</form>
		<script>
// 验证,然后 保存界面
function savePageName()
{


var topic_title =$('#topic_title').val();
var topic_overview=$('#topic_overview').val();
var topic_change = $('#topic_change').val();
var topic_type = $('#topic_type').val();
var keywords = $('#keywords').val();
var topic_author = $('#topic_author').val();
var topic_description = $('#topic_description').val();
var topic_from = $('#topic_from').val();
var id = $('#id').val();

var sendData="topic_title="+ encodeURIComponent(topic_title)+"&topic_overview="+encodeURIComponent(topic_overview)
+"&topic_author="+encodeURIComponent(topic_author)+"&topic_description="+encodeURIComponent(topic_description)+
"&keywords="+keywords+"&topic_change="+topic_change+"&topic_type="+topic_type+"&id="+id+"&topic_from="+encodeURIComponent(topic_from); 

    		$.ajax({ 
			url: "<%=path%>/updateTopic.do" ,
			type:'post', //数据发送方式 
			dataType:'action', //接受数据格式 
			data: sendData , 
			// beforeSend: function() {$("<img src='../images/wait18.gif' />").appendTo("#DivTblContact")},  
			success:update_page //回传函数(这里是函数名)   error转向错误页面
            }); 
            
}
    function update_page(obj) { //ajax保存成功后,触发 id为rain 的onclick事件
         window.location.reload();
     } 		 
function dele_pic(obj) { //ajax保存成功后,触发 id为rain 的onclick事件
        // window.location.reload();
         alert("图片删除成功");
     } 	
function getKeyWord(){
	var theUrl = "<%=path%>/pages/admin/topicmanager/keywordinfo.jsp";
	var width = 500;
	var heigh = 400;
	window.open(theUrl,'','menubar=no, z-look=yes, scrollbars=yes, toolbar=no, status=yes, resizable=no, width='+ width +', height='+heigh);

}
function deletePic(id,picpath){
	$.ajax({ 
								url: "<%=path%>/deletePic.do" ,
								type:'post', 
								dataType:'action', 
								data: {picpath:picpath,id:id} ,  
								success:dele_pic 
	           					}); 
}

</script>
	</body>
</html>
